# 导包
import pymysql

# 建立连接
conn = pymysql.connect(host='localhost', port=3306, user='root', password='root', database='advanced', charset='utf8')

# 获取游标(指针)
cursor = conn.cursor()

# 执行SQL语句
cursor.execute('select version();')

# 获取结果
res = cursor.fetchone()
print(res)

# 关闭游标
cursor.close()

# 关闭链接
conn.close()